home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-05 | 1.6 KB | 86 lines | [TEXT/MPS ] |
- /*
- File: mtb12.c
- Contains: Sound Functions
- Written by: DTS and QT Engineering
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
- Change History (most recent first):
- <1> 12/4/94 khs changed the format of the file to the new look and feel
- To Do:
- */
-
-
- // INCLUDES
- #include "mtb.h"
-
-
- // TYPEDEFS AND STRUCTS
- typedef SndCommand* SndCmdPtr;
-
- typedef struct
- {
- short format;
- short numSynths;
- } Snd1Header, * Snd1HdrPtr, ** Snd1HdrHndl;
-
- typedef struct
- {
- short format;
- short refCount;
- } Snd2Header, * Snd2HdrPtr, ** Snd2HdrHndl;
-
- typedef struct
- {
- short synthID;
- long initOption;
- } SynthInfo, * SynthInfoPtr;
-
-
- // FUNCTIONS
- long GetSndHdrOffset(Handle sndHandle)
- {
- short howManyCmds;
- long sndOffset = 0;
- Ptr sndPtr;
-
- if (sndHandle == nil)
- return 0;
- sndPtr = *sndHandle;
- if (sndPtr == nil)
- return 0;
-
- if ((*(Snd1HdrPtr)sndPtr).format == firstSoundFormat)
- {
- short synths = ((Snd1HdrPtr)sndPtr)->numSynths;
- sndPtr += sizeof(Snd1Header) + (sizeof(SynthInfo) * synths);
- }
- else
- {
- sndPtr += sizeof(Snd2Header);
- }
-
- howManyCmds = *(short*)sndPtr;
-
- sndPtr += sizeof(howManyCmds);
- // sndPtr is now at the first sound command - cruise all
- // commands and find the first soundCmd or bufferCmd
- while (howManyCmds > 0)
- {
- switch (((SndCmdPtr)sndPtr)->cmd)
- {
- case (soundCmd + dataOffsetFlag):
- case (bufferCmd + dataOffsetFlag):
- sndOffset = ((SndCmdPtr)sndPtr)->param2;
- howManyCmds = 0; /* done, get out of loop */
- break;
- default: /* catch any other type of commands */
- sndPtr += sizeof(SndCommand);
- howManyCmds--;
- break;
- }
- } /* done with all the commands */
-
- return sndOffset;
- }
-
-
-